<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/10/12
 * Time: 14:39
 */
function upload($file,$folder){
    //获取表单上传文件
    //$file = request()->file('img');
    //移动到框架应用根目录/public/uploads/目录下
    //$info = $file->move(ROOT_PATH.'public'.DS.'uploads');
    $info = $file->validate(['size'=>815678,'ext'=>'jpg,png,gif'])->move('../uploads/',$folder);
    if ($info){
        //存入相对路径/uploads/日期/文件名
        //$data = DS.'uploads'.DS.$info->getSaveName();
        $image = $info->getSaveName();
        $images = str_replace("\\","/",$image);
        $img_path = '/uploads/'.$folder.'/'.$images;
        return $img_path;
    }else{
        //上传失败获取错误信息
        echo $file->getError();
    }
}